package Lee_code;

public class Lee_48 {

    public static void rotate() {

        int[][] matrix = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        int[][] matrix_2 = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        int hang = matrix.length;
        int[][] temp = new int[hang][hang];

        //i代指原数组的行, k为原数组的列
        for(int i=0; i<hang; i++)
        {
            //把原数组的行映射到新数组的列
            for(int k=0; k<hang; k++)
            {
                temp[k][hang-i-1] = matrix[i][k];
            }
        }
        matrix = temp;
        for (int[] ints : matrix_2) {
            //把原数组的行映射到新数组的列
            for (int k = 0; k < hang; k++) {
                System.out.print(ints[k]);
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        rotate();

    }

}
